package com.lagou.controller;

import com.lagou.pojo.ResultVO;
import com.lagou.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author czq
 * @date 2020/9/15 16:20
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 注册接⼝，true成功，false失败
     */
    @GetMapping("/register/{email}/{password}/{code}")
    public ResultVO register(@PathVariable("email") String email, @PathVariable("password") String password,
                             @PathVariable("code") String code, HttpServletResponse response) {
        return userService.register(email, password, code, response);
    }

    @GetMapping("/login/{email}/{password}")
    public ResultVO login(@PathVariable("email") String email, @PathVariable("password") String password,
                          HttpServletResponse response) {
        return userService.loign(email, password, response);
    }

    @GetMapping("/info/{token}")
    public ResultVO info(@PathVariable("token") String token, HttpServletResponse response) {
        return userService.info(token, response);
    }
}
